package com.saclub.app.fragment;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;

import com.saclub.app.activity.MyToolBarActivity;
import com.saclub.app.common.IBack;

public abstract class BackProgressFragment extends BaseProgressFragment<MyToolBarActivity> implements IBack {

	@Override
	protected int obtainContentRes() {
		return 0;
	}

	@Override
	public void loadFragment(int containResId, Fragment frag, boolean showBackLast) {

		FragmentManager fm = getChildFragmentManager();
		FragmentTransaction ft = fm.beginTransaction();
		ft.addToBackStack("cur_frag");//保存当前的Frag到栈
		ft.replace(containResId, frag, "other_frag");//替换为新的Frag
		ft.commit();

	}

	@Override
	public void onBackPressed() {
		
		FragmentManager fm = getChildFragmentManager();
		
		if(fm.getBackStackEntryCount() > 0){
			fm.popBackStack();
		}
	}

}
